package BinarySearch;

public class _73两数之和2_输入有序数组 {
    public static void main(String[] args) {

    }

//    官解二分查找    去开本身的二分查找
    public static int[] twoSum(int[] numbers, int target) {
      for (int i = 0; i < numbers.length; ++i) {
                  int low = i + 1, high = numbers.length - 1;
                  while (low <= high) {
                      int mid = (high - low) / 2 + low;
                      if (numbers[mid] == target - numbers[i]) {
                          return new int[]{i + 1, mid + 1};
                      } else if (numbers[mid] > target - numbers[i]) {
                          high = mid - 1;
                      } else {
                          low = mid + 1;
                      }
                  }
              }
              return new int[]{-1, -1};
    }
}
